#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn],n,tmp[maxn];
long long ans=0;

void mergesort(int l,int r){
	if(l==r)return;
	int mid=(l+r)/2;
	mergesort(l,mid);
	mergesort(mid+1,r);
	int i=l,t=l,j=mid+1;
	while(i<=mid && j<=r){
		if(a[i]<=a[j]){
			tmp[t++]=a[i++];
		}else{
			tmp[t++]=a[j++];
			ans+=mid-i+1;
		}
	}
	while(i<=mid){
		tmp[t++]=a[i++];
	}
	while(j<=r){
		tmp[t++]=a[j++];
	}
	for(i=l;i<=r;i++){
		a[i]=tmp[i];
	}
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	mergesort(1,n);
	cout<<ans<<endl;
	return 0;
	
}